<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>Asset Class - Fuel Documentation</title>
	<link href="../assets/css/main.css" media="screen" rel="stylesheet" />
	<script type="text/javascript" src="../assets/js/jquery-1.4.4.min.js"></script>
	<script type="text/javascript" src="../assets/js/nav.js"></script>
	<script type="text/javascript" src="../assets/js/highlight.pack.js"></script>
	<script type="text/javascript">
		$(function() {
			show_nav('classes', '../');
		});
		hljs.tabReplace = '    ';
		hljs.initHighlightingOnLoad();
	</script>
</head>
<body>

	<header>
		<h1>Fuel Documentation</h1>
	</header>

	<div id="main-nav"></div>

	<section id="content">
		<h2>Asset Class</h2>

		<p>The asset class is a set of methods to help with the collection, grouping and displaying of assets (js, css, img). Each asset is a RELATIVE path from the base_url WITH a trailing slash.</p>

		<article>
			<h4>add_path($path)</h4>
			<p>The <strong>add_path</strong> method adds the given path to the front of the assets path array.</p>
			<table class="method">
				<tbody>
				<tr>
					<th class="legend">Static</th>
					<td>Yes</td>
				</tr>
				<tr>
					<th>Parameters</th>
					<td>
						<table class="parameters">
							<tr>
								<th>Param</th>
								<th>Default</th>
								<th class="description">Description</th>
							</tr>
							<tr>
								<th><kbd>$path</kbd></th>
								<td><i>required</i></td>
								<td>The path to add to the front of the assets path array (RELATIVE to base url WITH trailing slash).</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<th>Returns</th>
					<td>void</td>
				</tr>
				<tr>
					<th>Example</th>
					<td>
<pre class="php"><code>Asset::add_path('resources/template_1/');

Asset::add_path('resources/template_2/');

/* 
NOTE: The paths referenced above would need to have subfolders of js, css, and/or img
depending on the type of content you were trying to use.
*/</code></pre>
					</td>
				</tr>
				</tbody>
			</table>
		</article>
		
		<article>
			<h4>css($stylesheets = array(), $attr = array(), $group = NULL, $raw = false)</h4>
			<p>The <strong>css</strong> method adds css to a group or returns the css tag.</p>
			<table class="method">
				<tbody>
				<tr>
					<th class="legend">Static</th>
					<td>Yes</td>
				</tr>
				<tr>
					<th>Parameters</th>
					<td>
						<table class="parameters">
							<tr>
								<th>Param</th>
								<th>Default</th>
								<th class="description">Description</th>
							</tr>
							<tr>
								<th><kbd>$stylesheets</kbd></th>
								<td><i>required</i></td>
								<td>An array/string of stylesheet filename(s) to be added to the group or be returned as tags.</td>
							</tr>
							<tr>
								<th><kbd>$attr</kbd></th>
								<td><pre class="php"><code>array()</code></pre></td>
								<td>An array of attributes to be applied to the css file(s).</td>
							</tr>
							<tr>
								<th><kbd>$group</kbd></th>
								<td><pre class="php"><code>null</code></pre></td>
								<td>A group name to categorize the css. If left null the method will return the css tag.</td>
							</tr>
							<tr>
								<th><kbd>$raw</kbd></th>
								<td><pre class="php"><code>false</code></pre></td>
								<td>If set to true the result css tags will include the file contents directly instead of via a link tag.</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<th>Returns</th>
					<td>string</td>
				</tr>
				<tr>
					<th>Example</th>
					<td>
<pre class="php"><code>// adds file to group and returns '' if group is not null
Asset::css(array('header.css', 'footer.css'), array(), 'layout', false);

/* returns
&lt;link href="../assets/css/inline.css" rel="stylesheet" /&gt;
*/
echo Asset::css('inline.css');

/* returns 
&lt;style&gt;
.bold_class { font-weight: bold }
#header {height: 50px}
&lt;/style&gt;
*/
echo Asset::css('inline.css', array(), null, true);</code></pre>
					</td>
				</tr>
				</tbody>
			</table>
		</article>
		
		<article>
			<h4>find_file($file, $folder)</h4>
			<p>The <strong>find_file</strong> locates a file in all the asset paths.</p>
			<table class="method">
				<tbody>
				<tr>
					<th class="legend">Static</th>
					<td>Yes</td>
				</tr>
				<tr>
					<th>Parameters</th>
					<td>
						<table class="parameters">
							<tr>
								<th>Param</th>
								<th>Default</th>
								<th class="description">Description</th>
							</tr>
							<tr>
								<th><kbd>$file</kbd></th>
								<td><i>required</i></td>
								<td>The name of the file you are searching for.</td>
							</tr>
							<tr>
								<th><kbd>$folder</kbd></th>
								<td><i>required</i></td>
								<td>The name of the folder which contains the file you are looking for (css, js, img).</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<th>Returns</th>
					<td>Either the path to the file or false if not found</td>
				</tr>
				<tr>
					<th>Example</th>
					<td>
<pre class="php"><code>$path = Asset::find_file('layout.css', 'css');</code></pre>
					</td>
				</tr>
				</tbody>
			</table>
		</article>
		
		<article>
			<h4>img($images = array(), $attr = array(), $group = NULL)</h4>
			<p>The <strong>img</strong> either adds the image to the group, or returns the image tag.</p>
			<table class="method">
				<tbody>
				<tr>
					<th class="legend">Static</th>
					<td>Yes</td>
				</tr>
				<tr>
					<th>Parameters</th>
					<td>
						<table class="parameters">
							<tr>
								<th>Param</th>
								<th>Default</th>
								<th class="description">Description</th>
							</tr>
							<tr>
								<th><kbd>$images</kbd></th>
								<td><i>required</i></td>
								<td>An array/string of image filename(s) to be applied to the group or returned as tags.</td>
							</tr>
							<tr>
								<th><kbd>$attr</kbd></th>
								<td><pre class="php"><code>array()</code></pre></td>
								<td>An array of attributes to apply to the image tag(s).</td>
							</tr>
							<tr>
								<th><kbd>$group</kbd></th>
								<td><pre class="php"><code>null</code></pre></td>
								<td>The group to apply the images to.</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<th>Returns</th>
					<td>string</td>
				</tr>
				<tr>
					<th>Example</th>
					<td>
<pre class="php"><code>// returns &lt;img src="../assets/img/logo.png" id="logo"&gt;
echo Asset::img('logo.png', array('id' => 'logo'));

Asset::img(array('bob.jpg', 'joe.jpg', 'sally.jpg'), array('class' => 'thumbnail'), 'team_avatars');</code></pre>
					</td>
				</tr>
				</tbody>
			</table>
		</article>
		
		<article>
			<h4>js($scripts = array(), $attr = array(), $group = NULL, $raw = false)</h4>
			<p>The <strong>js</strong> either adds the javascript to the group, or returns the script tag.</p>
			<table class="method">
				<tbody>
				<tr>
					<th class="legend">Static</th>
					<td>Yes</td>
				</tr>
				<tr>
					<th>Parameters</th>
					<td>
						<table class="parameters">
							<tr>
								<th>Param</th>
								<th>Default</th>
								<th class="description">Description</th>
							</tr>
							<tr>
								<th><kbd>$scripts</kbd></th>
								<td><i>required</i></td>
								<td>An array/string of stylesheet filename(s) to be added to the group or be returned as tags.</td>
							</tr>
							<tr>
								<th><kbd>$attr</kbd></th>
								<td><pre class="php"><code>array()</code></pre></td>
								<td>An array of attributes to be applied to the js file(s).</td>
							</tr>
							<tr>
								<th><kbd>$group</kbd></th>
								<td><pre class="php"><code>null</code></pre></td>
								<td>A group name to categorize the js. If left null the method will return the js tag.</td>
							</tr>
							<tr>
								<th><kbd>$raw</kbd></th>
								<td><pre class="php"><code>false</code></pre></td>
								<td>If set to true the result js tags will include the file contents directly instead of via a script src tag.</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<th>Returns</th>
					<td>string</td>
				</tr>
				<tr>
					<th>Example</th>
					<td>
<pre class="php"><code>// returns '' if $raw is set to false
Asset::js(array('jquery.js', 'jqueryui.js'), array(), 'jquery', false);

/* returns
&lt;script type="text/javascript"&gt;
var menu = getElementById('menu');
menu.initialize_menu();
&lt;/script&gt;
*/
echo Asset::css('menu_init.js', array(), null, true);

// returns &lt;script type="text/javascript" src="../assets/js/jquery.js"&gt;&lt;/script&gt;
echo Asset::js('jquery.js');</code></pre>
					</td>
				</tr>
				</tbody>
			</table>
		</article>
	
		<article>
			<h4>remove_path($path)</h4>
			<p>The <strong>remove_path</strong> removes the given path from the asset paths array</p>
			<table class="method">
				<tbody>
				<tr>
					<th class="legend">Static</th>
					<td>Yes</td>
				</tr>
				<tr>
					<th>Parameters</th>
					<td>
						<table class="parameters">
							<tr>
								<th>Param</th>
								<th>Default</th>
								<th class="description">Description</th>
							</tr>
							<tr>
								<th><kbd>$path</kbd></th>
								<td><i>required</i></td>
								<td>The path to from the assets path array.</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<th>Returns</th>
					<td>void</td>
				</tr>
				<tr>
					<th>Example</th>
					<td>
<pre class="php"><code>Asset::remove_path('resources/template_1/');

Asset::remove_path('resources/template_2/');</code></pre>
					</td>
				</tr>
				</tbody>
			</table>
		</article>
		
		<article>
			<h4>render($group, $raw = false)</h4>
			<p>The <strong>render</strong> renders the group of assets and returns the tags.</p>
			<table class="method">
				<tbody>
				<tr>
					<th class="legend">Static</th>
					<td>Yes</td>
				</tr>
				<tr>
					<th>Parameters</th>
					<td>
						<table class="parameters">
							<tr>
								<th>Param</th>
								<th>Default</th>
								<th class="description">Description</th>
							</tr>
							<tr>
								<th><kbd>$group</kbd></th>
								<td><i>required</i></td>
								<td>The name of the group to render.</td>
							</tr>
							<tr>
								<th><kbd>$raw</kbd></th>
								<td><pre class="php"><code>false</code></pre></td>
								<td>If true this method will return an internal css/js tags.</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<th>Returns</th>
					<td>string</td>
				</tr>
				<tr>
					<th>Example</th>
					<td>
<pre class="php"><code>/* returns
&lt;link href="../assets/css/header.css" rel="stylesheet" /&gt;
&lt;link href="../assets/css/footer.css" rel="stylesheet" /&gt;
*/
echo Asset::render('layout');</code></pre>
					</td>
				</tr>
				</tbody>
			</table>
		</article>
	</section>
	<section id="footer">
		<p>
			<a href="http://fuelphp.com">Fuel</a> is released under the MIT license.<br />
			&copy; 2010 - 2011 Fuel Development Team
		</p>
	</section>

</body>
</html>